
	

import delimited  "$data_folder/positivos_covid.csv", clear  delimiter(";")


tostring fecha_resultado, replace 

gen date = date(fecha_resultado,"YMD")

format date %td

gen monthlyDate = mofd(date)
gen month = month(date)
gen year = year(date)


gen aprMay = inlist(month, 4,5) & year == 2020
gen julAug = inlist(month, 7,8) & year == 2020

gen both = aprMay | julAug

keep if both 

gen cases = 1 

collapse (count) cases, by(ubigeo  aprMay julAug)

//this is the weird year used in the panel data 
gen year = .
replace year = 2020 if aprMay
replace year = 2021 if julAug

keep year ubigeo cases


tempfile infex
sa `infex'



import delimited  "$data_folder/fallecidos_covid.csv", clear  delimiter(";")


tostring fecha_fallecimiento, replace 

gen date = date(fecha_fallecimiento,"YMD")

format date %td

gen monthlyDate = mofd(date)
gen month = month(date)
gen year = year(date)


gen aprMay = inlist(month, 4,5) & year == 2020
gen julAug = inlist(month, 7,8) & year == 2020

gen both = aprMay | julAug

keep if both 

gen deaths = 1 

collapse (count) deaths, by(ubigeo  aprMay julAug)


//this is the weird year used in the panel data 
gen year = .
replace year = 2020 if aprMay
replace year = 2021 if julAug

keep year ubigeo deaths
merge 1:1 year ubigeo using `infex' 



drop _merge 

mvencode deaths cases, mv(0) override


tostring ubigeo, replace 
sa "$data_folder/covid_ubigeo.dta", replace 



